lib/sysroot: Fix retrieving non-booted pending deployment
authorJonathan Lebon <jlebon@redhat.com>
Wed, 28 Feb 2018 17:30:18 +0000 (17:30 +0000)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 28 Feb 2018 18:09:13 +0000 (18:09 +0000)
If we're booted into a deployment, then any queries for the pending
merge deployment of a non-booted OS will fail due all of them being
considered rollback.

Fix this by filtering by `osname` *before* determining if we've crossed
the booted deployment yet.

Closes: #1472
Approved by: cgwalters

src/libostree/ostree-sysroot.c

index 2c12b78b334159271344dd463fe6e9728c3ae6ce..2d12deb63e7ba10a4a7ab0e350a7a38cf0a4993b 100644 (file)
@@ -1202,6 +1202,10 @@ ostree_sysroot_query_deployments_for (OstreeSysroot     *self,
     {
       OstreeDeployment *deployment = self->deployments->pdata[i];
 
+      /* Ignore deployments not for this osname */
+      if (strcmp (ostree_deployment_get_osname (deployment), osname) != 0)
+          continue;
+
       /* Is this deployment booted?  If so, note we're past the booted */
       if (self->booted_deployment != NULL &&
           ostree_deployment_equal (deployment, self->booted_deployment))
@@ -1210,10 +1214,6 @@ ostree_sysroot_query_deployments_for (OstreeSysroot     *self,
           continue;
         }
 
-      /* Ignore deployments not for this osname */
-      if (strcmp (ostree_deployment_get_osname (deployment), osname) != 0)
-          continue;
-
       if (!found_booted && !ret_pending)
         ret_pending = g_object_ref (deployment);
       else if (found_booted && !ret_rollback)